import { BelongsToMany, Column, DataType, Model, Table } from "sequelize-typescript";
import SysUser from "./sys.user.entity";
import SysUserRole from "./user.role.entity";

@Table({
    underscored: true,
    comment: '角色表',
    tableName: 'sys_role',
    freezeTableName: true
})
class SysRole extends Model<SysRole> {
    @Column({
        unique: true,
        primaryKey: true,
        autoIncrement: true,
        allowNull: false,
        comment: '角色id'
    })
    id: number;

    @Column({
        type: DataType.CHAR(255),
        unique: true,
        allowNull: false,
        comment: '角色名称'
    })
    name: string

    @Column({
        type: DataType.CHAR(255),
        allowNull: true,
        comment: '角色描述'
    })
    description: string

    @BelongsToMany(() =>SysUser, () => SysUserRole)
    users:  Array<SysUser>
}
export default SysRole;